﻿using System.Data.Entity;
using LabNet.Server.Domain;

namespace LabNet.Server.Configuration
{
    public class GroupConfiguration
    {
        public static void Map(DbModelBuilder modelBuilder)
        {
            modelBuilder
                .Entity<Group>()
                .ToTable("Group");

            modelBuilder
                .Entity<Group>()
                .HasMany(o => o.Users)
                .WithRequired(o => o.Group)
                .HasForeignKey(o => o.GroupId);

            modelBuilder
               .Entity<Group>()
               .HasMany(o => o.Roles)
               .WithRequired(o => o.Group)
               .HasForeignKey(o => o.GroupId);

        }
    }
}
